package com.stormdemo.topn.bolt;

import backtype.storm.topology.BasicOutputCollector;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.topology.base.BaseBasicBolt;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Tuple;
import backtype.storm.tuple.Values;

public class transfBolt extends BaseBasicBolt {
	@Override
	public void declareOutputFields(OutputFieldsDeclarer declarer) {
		declarer.declare(new Fields("transf"));
	}

	@Override
	public void execute(Tuple input, BasicOutputCollector collector) {
		String value = input.getStringByField("word");
		String sentence = input.getString(0);
		String[] words = sentence.split(" ");

		for (String word : words) {
			collector.emit(new Values(word));
		}
	}
}
